<?php
require('../config.php');

		$sql="select s.id,s.sid,s.shop_id,s.title,s.qishu,s.thumb,s.q_uid from `".$oto."_shoplist` as s where `q_user_code` is not null and `q_showtime`='N' order by q_end_time DESC LIMIT 4";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$jjjx_list[]=$row;//将取得的所有数据赋值给person_info数组
		}
		if(isset($jjjx_list))
		{
			for($i=0;$i<count($jjjx_list);$i++)
			{
				$user_id=$jjjx_list[$i]['q_uid'];
				$sql="select userName from `".$oto."_users` where `userId`='{$user_id}'";
				$result=$db->query($sql);
				while($row=$result->fetch_assoc()){
					$users[$i]=$row;//将取得的所有数据赋值给person_info数组
				}
				if(isset($users[$i]))
				{
					$jjjx_list[$i]['userName']=$users[$i]['userName'];
				}
				else $jjjx_list[$i]['userName']="";
				$sid=$jjjx_list[$i]['sid'];
				//获取期数
				$sql="select s.qishu from `".$oto."_shoplist` as s where sid='{$sid}' order by qishu desc limit 1";
				$result=$db->query($sql);
				while($row=$result->fetch_assoc()){
					$qishu_info=$row;
				}
				if(isset($qishu_info)) $jjjx_list[$i]['max_qishu']=$qishu_info['qishu'];
				else $jjjx_list[$i]['max_qishu']="";
			}
			echo json_encode($jjjx_list);
		}
		else 
		{
			echo '[]';
		}
?>